function phi = phiUpdate(phi,mphi,nelx,nely,h,dt,kappa);
% phi = phiUpdate(phi,mphi,nelx,nely,h,dt,kappa);
% FDM version on nonuniform mesh calculation!
%
% update phi with semi-implicit scheme for phase equation
%
%  \phi_t = \kappa \triangle \phi + \phi(1-\phi)r(\phi)
%  with neumann boundary conditions
% %
  mphi = reshape(mphi.*phi.*(1-phi),nelx,nely)';
  phi = reshape(phi,nelx,nely)'; %Reshape phase field function for easy calcuration of finite difference method.





  
%Clip phi the range between 0 to 1.
  phi =  max(0,min(1, phi)); 
